package com.itheima.controller;

import com.itheima.common.vo.Result;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("user")
public class UserController {


    @GetMapping("add")
    //代表此接口 必须要有add的权限才能访问
//    @PreAuthorize("hasAuthority('add')")
    public Result add(){
        return Result.success("add");
    }

    @GetMapping("find")
    //代表此接口 必须要有ROLE_ADMIN的角色才能访问
//    @PreAuthorize("hasRole('ROLE_ADMIN')")
    public Result find(){
        return Result.success("find");
    }

    @GetMapping("delete")
    //代表此接口 必须要有delete的权限才能访问
//    @PreAuthorize("hasAuthority('delete')")
    public Result delete(){
        return Result.success("delete");
    }

    @GetMapping("update")
    //代表此接口 只要登录就能访问
//    @PreAuthorize("isAuthenticated()")
    public Result update(){
        return Result.success("update");
    }
 }
